using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Common;
using IGlobalist.Cms.Model;

namespace IGlobalist.Cms.Admin.Control
{
    public partial class MainMenu : AdminBaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (IGlobalistMembership.IsAuthenticate){
                    string xpath = "";
                    if (IGlobalistMembership.IsInRole(BuiltinRole.SysAdmin))
                        xpath=String.Format("/mainmenu/menuitem[contains(@roles,'{0}')]", BuiltinRole.SysAdmin.ToString());
                    else
                    if (IGlobalistMembership.IsInRole(BuiltinRole.ContentAdmin))
                        xpath = String.Format("/mainmenu/menuitem[contains(@roles,'{0}')]", BuiltinRole.ContentAdmin.ToString());
                    else
                    if (IGlobalistMembership.IsInRole(BuiltinRole.Editor))
                        xpath = String.Format("/mainmenu/menuitem[contains(@roles,'{0}')]", BuiltinRole.Editor.ToString());
                    else
                    if (IGlobalistMembership.IsInRole(BuiltinRole.Author))
                        xpath = String.Format("/mainmenu/menuitem[contains(@roles,'{0}')]", BuiltinRole.Author.ToString());
                    else
                    if (IGlobalistMembership.IsInRole(BuiltinRole.Member))
                        xpath = String.Format("/mainmenu/menuitem[contains(@roles,'{0}')]", BuiltinRole.Member.ToString());
                    else
                    if (IGlobalistMembership.IsInRole(BuiltinRole.Guest))
                        xpath = String.Format("/mainmenu/menuitem[contains(@roles,'{0}')]", BuiltinRole.Guest.ToString());
                    XmlDataSource.XPath=xpath;
                }
            }
        }
    }
}